// 获取定位信息
export function getLocation() {
	return new Promise((resolve, reject) => {
		uni.getLocation({
			type: 'gcj02',
			// type: 'wgs84',
			geocode: true,
			accuracy: 'best',
			isHighAccuracy: true,
			success: (res) => {
				resolve(res)
			},
			fail: (err) => {
				reject(err)
			},
			complete: (res) => {}
		})
	})
}
export function isPointInPolygon(x, y, polygon) {
  // 点P的坐标
  const px = x;
  const py = y;

  let c = false; // 交点的数量，初始化为0

  // 遍历多边形的每条边
  for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
    const xi = polygon[i][0], yi = polygon[i][1];
    const xj = polygon[j][0], yj = polygon[j][1];

    // 检查点P是否在边(xi, yi)和边(xj, yj)的延长线上
    const dx = xj - xi;
    const dy = yj - yi;

    if (((yi > py) !== (yj > py)) &&
        (px < (xj - xi) * (py - yi) / (yj - yi) + xi)) {
      c = !c;
    }
  }

  // 如果交点数量为奇数，则点在多边形内
  return c;
}